package pack0701;

import java.util.InputMismatchException;
import java.util.Scanner;

//演示throw关键字
public class Test2 {
    public void print(){

            try{
                Scanner scan =new Scanner(System.in);
                System.out.println("请输入第一个数: ");
                int a= scan.nextInt();
                System.out.println("请输入第二个数: ");
                int b= scan.nextInt();

                System.out.println("除法的结果: "+a/b);
            }catch (Exception a){
                throw a;
            }

        System.out.println("计算完毕");
    }

    public void sing(){
        try{
            print();
        }catch(InputMismatchException e){
            System.out.println("抓住了输入不匹配异常");
        }
    }

    public static void main(String[] args) {
        Test2 t=new Test2();
        try{
            t.sing();
        }catch(ArithmeticException e){
            System.out.println("抓住了数学异常");
        }
        System.out.println("aaaaaaaaaa");
    }


}
